<?php
$v_record_id = 0;
if(isset($_REQUEST['hdn_record_id'])){
	$v_record_id = intval($_REQUEST['hdn_record_id']);
}
$_v_list_record_id="";
if(isset($_REQUEST['hdn_record_id_list'])){
	$_v_list_record_id=$_REQUEST['hdn_record_id_list'];
	$v_arrs_record_id=explode(",",$_REQUEST['hdn_record_id_list']);
}
$v_status = 1;
$v_filter = "";
$v_cate_id= 0;
$v_recordtype_filter2 = $_SESSION['onegate_current_recordtype'];
if(isset($_REQUEST['hdn_recordtype_filter'])){
	$v_recordtype_filter2=$_REQUEST['hdn_recordtype_filter'];
}
if(_is_sqlserver()){
	$v_c_code ="";
	if(sizeof($v_arrs_record_id)==1){
		if($v_arrs_record_id[0]==""){
			$v_record_id=$v_record_id;
		}else{
			$v_record_id=$v_arrs_record_id[0];
		}
		
		$sql = "Exec Onegate_RecordGetSingle " . $v_record_id;
		$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
		$arr_single_record = $ado_conn->GetRow($sql);
		$v_recordtype_name2 = $arr_single_record['C_RECORDTYPE_NAME'];
		$v_c_code=$v_c_code.$arr_single_record['C_CODE'];
		$_v_list_record_id=$v_arrs_record_id[0];
		$c_details_status=$arr_single_record['C_DETAIL_STATUS'];
		//echo 'c_details_status='.$c_details_status;
		//$v_staff_id = $_SESSION['staff_id'];
		$v_id_staff_handler=$arr_single_record['FK_HANDLER'];
		if($v_id_staff_handler==$_SESSION['staff_id']){
			$is_handler_this_records=true;
		}else{
			$is_handler_this_records=false;
		}
	}else{
		for($i=0;$i<sizeof($v_arrs_record_id);$i++){
			$v_count=sizeof($v_arrs_record_id)-1;
			$v_id_record_i=$v_arrs_record_id[$i];
			$sql = "Exec Onegate_RecordGetSingle " . $v_id_record_i;
			$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
			$arr_single_record_i = $ado_conn->GetRow($sql);
			$v_recordtype_name2 = $arr_single_record_i['C_RECORDTYPE_NAME'];
			
			$c_details_status=$arr_single_record_i['C_DETAIL_STATUS'];
			$v_id_staff_handler=$arr_single_record_i['FK_HANDLER'];
		if($i==$v_count){
			$v_c_code=$v_c_code.$arr_single_record_i['C_CODE'];
		}else{
			$v_c_code=$v_c_code.$arr_single_record_i['C_CODE']." , ";
		}
	}
}
	//var_dump ($arr_single_record);
	$sql = "Exec ONEGATE_RecordtypeGetAll " ;
	$sql = $sql.$v_status.",";
	$sql = $sql.$v_cate_id.",";
	$sql = $sql."'".$v_filter."'";
	
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$arr_all_recordtype = $ado_conn->GetAll($sql); 
	
	$sql = "Exec Onegate_IdeaGetAll ";
	$sql = $sql .$v_record_id;
	
	$ado_conn->SetFetchMode(ADODB_FETCH_NUM);
	$arr_all_idea = $ado_conn->GetAll($sql);
	$v_count_idea = sizeof($arr_all_idea);
	///
	$sql_single_config="Exec Onegate_ConfigRecordtypeGetSingle ";
	$sql_single_config=$sql_single_config."'".$v_recordtype_filter."'";
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$arr_single_config = $ado_conn->GetRow($sql_single_config); 
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
	$v_c_system_conf=$arr_single_config['C_SYSTEM_CONFIG'];
}?>
